<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/10/27
 * Time: 9:25
 */
namespace zhtfrontend\modules\sitepadapi\controllers;

use zhtfrontend\modules\sitepadapi\components\rest\ActiveController;
use yii\data\ActiveDataProvider;
use yii\web\Response;

class IndentController extends ActiveController
{
    public $modelClass = 'zhtfrontend\models\datas\Order';

    public $serializer = [
        'class' => 'zhtfrontend\modules\sitepadapi\components\rest\Serializer',
        'collectionEnvelope' => 'items',
    ];

    public function behaviors()
    {
        $behaviors = parent::behaviors();
        $behaviors['contentNegotiator']['formats']['text/html'] = Response::FORMAT_JSON;
        return $behaviors;
    }

    public function actions()
    {
        $actions = parent::actions();
        unset($actions['index'], $actions['create'], $actions['update'], $actions['delete'], $actions['view']);
        return $actions;
    }

    public function actionFindbycid($customer_id)
    {
        $modelClass = $this->modelClass;
        $model = $modelClass::find()->where(['customer_id' => $customer_id]);
        return new ActiveDataProvider([
            'query' => $model
        ]);
    }
}